Stepper 27 Click
Stepper 27 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Apr 2025.
- Type : GPIO type
Software Support
Example Description
This example demonstrates the use of the Stepper 27 Click board by driving the motor in both directions for a desired number of steps.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Stepper27
Example Key Functions
- stepper27_cfg_setup This function initializes Click configuration structure to initial values.
void stepper27_cfg_setup(stepper27_cfg_t *cfg)
Stepper 27 configuration object setup function.
Stepper 27 Click configuration object.
Definition stepper27.h:138
- stepper27_init This function initializes all necessary pins and peripherals used for this Click board.
err_t stepper27_init(stepper27_t *ctx, stepper27_cfg_t *cfg)
Stepper 27 initialization function.
Stepper 27 Click context object.
Definition stepper27.h:123
- stepper27_set_direction This function sets the motor direction by setting the DIR pin logic state.
void stepper27_set_direction(stepper27_t *ctx, uint8_t dir)
Stepper 27 set direction function.
- stepper27_drive_motor This function drives the motor for the specific number of steps at the selected speed.
void stepper27_drive_motor(stepper27_t *ctx, uint32_t steps, uint8_t speed)
Stepper 27 driver motor function.
Application Init
Initializes the driver and resets the device.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( DIGITAL_OUT_UNSUPPORTED_PIN ==
stepper27_init( &stepper27, &stepper27_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define STEPPER27_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition stepper27.h:108
void stepper27_reset_device(stepper27_t *ctx)
Stepper 27 reset device function.
void application_init(void)
Definition main.c:34
#define MIKROBUS_POSITION_STEPPER27
Definition main.c:28
Application Task
Drives the motor clockwise for 100 slow steps and 300 medium speed steps and then counter-clockwise for 400 fast steps with a 1 second delay on driving mode change. All data is being logged on the USB UART where you can track the program flow.
{
log_printf ( &logger, " Move 100 steps clockwise, speed: slow\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 300 steps clockwise, speed: medium\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 400 steps counter-clockwise, speed: fast\r\n\n" );
Delay_ms ( 1000 );
}
#define STEPPER27_SPEED_MEDIUM
Definition stepper27.h:88
#define STEPPER27_SPEED_SLOW
Definition stepper27.h:87
#define STEPPER27_SPEED_FAST
Definition stepper27.h:89
#define STEPPER27_DIR_CCW
Definition stepper27.h:73
#define STEPPER27_DIR_CW
Stepper 27 direction setting.
Definition stepper27.h:72
void application_task(void)
Definition main.c:66
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.